﻿<?php
// 本类由系统自动生成，仅供测试用途
class IndexAction extends CommonAction {
    public function index(){
		$m=D('Message');
		
		import('ORG.Util.Page');//导入分页类
		$count=$m->count();
		$page=new Page($count,2);
		$show=$page->show();//返回分页信息
		
		$arr=$m->relation(true)->limit($page->firstRow.','.$page->listRows)->select();
		
		$this->assign('message',$arr);
		$this->assign('show',$show);
		$this->display();//跳转页面LoginAction.calss.php下的login方
	
	}
	public function top(){
		//$this->assign('name',$_SESSION['username']);
		$this->display();
	}
	
	public function message(){
		$m=	D('Message');
		$m->create();
		import('ORG.Net.UploadFile');
		$upload = new UploadFile();// 实例化上传类
		$upload->savePath =  './Public/Uploads/';// 设置附件上传目录
		if(!$upload->upload()) {// 上传错误提示错误信息
			$this->error($upload->getErrorMsg());
		}else{// 上传成功 获取上传文件信息
			$info =  $upload->getUploadFileInfo();
		}
		//dump($info);
		$m->filename=$info[0]['savename'];
		//$m->time=time();
		//$m->uid=$_SESSION['id'];

		$mes=$m->add();
		if($mes){$this->success('插的很爽',U('Index/index'));
			
		}else{
			$this->error('插不进去');
		}
	}
}